
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"

class OneLoop {
public:
    struct Range{
        int a;
        int b;
        bool has_p(int p){
            return p>=a&&p<=b;
        }
    };
    std::vector<Range> ranges;
    std::vector<int> ps;
    std::unordered_map<int,char> map;
    bool run(
    ) {
        int a, b;
        if(std::cin>>a>>b){

        }else{
            return false;
        }

        for (int i = 0; i < a; ++i) {
            int p;
            std::cin>>p;
            ps.push_back(p);
        }
        for (int i = 0; i < b; ++i) {
            Range r;
            std::cin>>r.a>>r.b;
            ranges.push_back(r);
        }

        for(auto p:ps){
            bool ok= true;
            for(auto&r:ranges){
                if(!r.has_p(p)){
                    ok=false;
                    break;
                }
            }
            if(ok){
                map[p]=1;
            }
        }
        printf("%d\n",map.size());
        return true;
    }
};

class Solution {
public:
    void run() {

        bool first = true;
        int a, b, c, d, e;
        while(1){
            OneLoop l;
            if(!l.run()){
                return;
            }
        }


    }
};

int main() {
//    bool cur_num= true;
    Solution().run();
    return 0;
}

